// TODO: A way to add Icons that don't already exist?
// - Register them and add
// - Include SVG Source/Inline?
// - By URL, or own component?

// What KINDS of toolbar buttons do we have...
// - One's that dispatch commands
// - One's that set tool's active
// - More custom, like CINE
//    - Built in for one's like this, or custom components?

// Visible?
// Disabled?
// Based on contexts or misc. criteria?
//  -- ACTIVE_ROUTE::VIEWER
//  -- ACTIVE_VIEWPORT::CORNERSTONE
// setToolActive commands should receive the button event that triggered
// so we can do the "bind to this button" magic
import { TOOLBAR_BUTTON_TYPES } from '@ohif/core';
import DEFAULT_CONTEXT from './defaultContext';

const definitions = [
  {
    id: 'Select',
    label: 'Select',
    icon: 'pointer',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'Select' },
  },
  {
    id: 'Wwwc',
    label: 'Levels',
    icon: 'contrast',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'Wwwc' },
    buttons: [
      {
        id: 'Wwwc',
        label: 'Levels',
        icon: 'contrast',
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: { toolName: 'Wwwc' },
      },
      {
        id: 'Invert',
        label: 'Invert',
        icon: 'invert',
        //
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'invertViewport',
      },
      {
        id: 'WwwcRegion',
        label: 'ROI Window',
        icon: 'roi',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: { toolName: 'WwwcRegion' },
      },
      {
        id: 'WwwcReset',
        label: 'Wwwc Reset',
        icon: 'reset',
        //
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'resetWwwc',
      },
      {
        id: 'divider01',
        type: TOOLBAR_BUTTON_TYPES.DIVIDER,

      },
      {
        id: 'wlChest',
        label: 'Chest',
        icon: 'wl-chest',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: 40, window: 350 },
      },
      {
        id: 'wlAbdomen',
        label: 'Abdomen',
        icon: 'wl-abdomen',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: 60, window: 360 },
      },
      {
        id: 'wlLung',
        label: 'Lung',
        icon: 'wl-lung',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: -600, window: 1500 },
      },
      {
        id: 'wlBone',
        label: 'Bone',
        icon: 'wl-bone',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: 480, window: 2500 },
      },
      {
        id: 'wlHead',
        label: 'Head',
        icon: 'wl-head',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: 90, window: 350 },
      },
      {
        id: 'wlBrain',
        label: 'Brain',
        icon: 'wl-brain',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: 40, window: 80 },
      },
      {
        id: 'wlHeart',
        label: 'Heart',
        icon: 'wl-heart',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'setWindowLevel',
        commandOptions: { level: 300, window: 800 },
      },
    ]
  },
  {
    id: 'Invert',
    label: 'Invert',
    icon: 'invert',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'invertViewport',
  },
  {
    id: 'WwwcRegion',
    label: 'ROI Window',
    icon: 'roi',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'WwwcRegion' },
  },
  {
    id: 'StackScroll',
    label: 'Stack Scroll',
    icon: 'stack',
    // className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'StackScroll' },
  },
  {
    id: 'Zoom',
    label: 'Zoom',
    icon: 'zoom',
    // className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'Zoom' },
  },
  {
    id: 'Pan',
    label: 'Pan',
    icon: 'pan',
    // className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'Pan' },
  },
  {
    id: 'Magnify',
    label: 'Magnify',
    icon: 'magnifier',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'Magnify' },
  },
  // {
  //   id: 'Tools',
  //   label: 'Tools',
  //   className: 'hideOnDesktop',
  //   icon: 'tools',
  //   type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
  //   commandName: 'setToolActive',
  //   commandOptions: { toolName: 'StackScroll' },
  //   buttons: [
  // {
  //   id: 'StackScroll',
  //   label: 'Stack Scroll',
  //   icon: 'stack',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
  //   commandName: 'setToolActive',
  //   commandOptions: { toolName: 'StackScroll' },
  // },
  // {
  //   id: 'Zoom',
  //   label: 'Zoom',
  //   icon: 'zoom',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
  //   commandName: 'setToolActive',
  //   commandOptions: { toolName: 'Zoom' },
  // },
  // {
  //   id: 'Pan',
  //   label: 'Pan',
  //   icon: 'pan',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
  //   commandName: 'setToolActive',
  //   commandOptions: { toolName: 'Pan' },
  // },
  // {
  //   id: 'Magnify',
  //   label: 'Magnify',
  //   icon: 'magnifier',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
  //   commandName: 'setToolActive',
  //   commandOptions: { toolName: 'Magnify' },
  // },
  // {
  //   id: 'ResetViewport',
  //   label: 'Reset',
  //   icon: 'reset',
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'resetViewport',
  // },
  // {
  //   id: 'divider01',
  //   type: TOOLBAR_BUTTON_TYPES.DIVIDER,
  // },
  // {
  //   id: 'RotateRight',
  //   label: 'Rotate Right',
  //   icon: 'rotate',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'rotateViewportCW',
  // },
  // {
  //   id: 'FlipH',
  //   label: 'Flip H',
  //   icon: 'hflip',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'flipViewportHorizontal',
  // },
  // {
  //   id: 'FlipV',
  //   label: 'Flip V',
  //   icon: 'vflip',
  //   //
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'flipViewportVertical',
  // },
  // {
  //   id: 'ResetRotate',
  //   label: 'Reset Rotate',
  //   icon: 'reset',
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'resetRotate',
  // },
  // {
  //   id: 'divider02',
  //   type: TOOLBAR_BUTTON_TYPES.DIVIDER,
  // },
  // {
  //   id: 'vtkMPR',
  //   label: 'MPR',
  //   icon: 'mpr',
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'mpr2d',
  // },
  // {
  //   id: 'vtkVR',
  //   label: 'VR',
  //   icon: 'vr',
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'vtkVR',
  // },
  // {
  //   id: 'divider03',
  //   type: TOOLBAR_BUTTON_TYPES.DIVIDER,
  // },
  // {
  //   id: 'DownloadDICOM',
  //   label: 'Download DICOM',
  //   icon: 'download-dicom',
  //   className: 'hideOnPhone',
  //   type: TOOLBAR_BUTTON_TYPES.COMMAND,
  //   commandName: 'downloadDICOM',
  // },
  //   ]
  // },
  {
    id: 'RotateRight',
    label: 'Rotate Right',
    icon: 'rotate',
    // className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'rotateViewportCW',
    buttons: [
      {
        id: 'RotateRight',
        label: 'Rotate Right',
        icon: 'rotate',
        //
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'rotateViewportCW',
      },
      {
        id: 'FlipH',
        label: 'Flip H',
        icon: 'hflip',
        //
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'flipViewportHorizontal',
      },
      {
        id: 'FlipV',
        label: 'Flip V',
        icon: 'vflip',
        //
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'flipViewportVertical',
      },
      {
        id: 'divider03',
        type: TOOLBAR_BUTTON_TYPES.DIVIDER,
      },
      {
        id: 'ResetRotate',
        label: 'Reset Rotate',
        icon: 'reset',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'resetRotate',
      },
    ],
  },
  {
    id: 'ResetViewport',
    label: 'Reset',
    icon: 'reset',
    // className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'resetViewport',
  },
  {
    id: 'First',
    label: 'First',
    icon: 'first',
    className: 'hideOnPhone',
    nonContexify: true,
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'firstImage',
    commandOptions: { toolName: 'First' },
  },
  {
    id: 'Previous',
    label: 'Previous',
    icon: 'previous',
    className: 'hideOnPhone',
    nonContexify: true,
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'previousImage',
    commandOptions: { toolName: 'Previous' },
  },
  {
    id: 'Cine',
    label: 'Cine',
    labelWhenActive: 'Stop',
    icon: 'play',
    iconWhenActive: 'stop',
    type: TOOLBAR_BUTTON_TYPES.STATE,
    commandName: 'cinePlay',
    options: {
      keys: [
        'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
      ],
      values: [true],
    },
    buttons: [
      {
        id: 'First',
        label: 'First',
        icon: 'first',
        className: 'hideOnDesktop',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'firstImage',
        commandOptions: { toolName: 'First' },
      },
      {
        id: 'Previous',
        label: 'Previous',
        icon: 'previous',
        className: 'hideOnDesktop',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'previousImage',
        commandOptions: { toolName: 'Previous' },
      },
      {
        id: 'Next',
        label: 'Next',
        icon: 'next',
        className: 'hideOnDesktop',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'nextImage',
        commandOptions: { toolName: 'Next' },
      },
      {
        id: 'Last',
        label: 'Last',
        icon: 'last',
        className: 'hideOnDesktop',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'lastImage',
        commandOptions: { toolName: 'Last' },
      },
      {
        id: 'divider01',
        className: 'hideOnDesktop',
        type: TOOLBAR_BUTTON_TYPES.DIVIDER,
      },
      {
        id: 'CineFPSDefault',
        label: 'Cine FPS[Default]',
        icon: 'play',
        type: TOOLBAR_BUTTON_TYPES.STATE,
        commandName: 'cinePlay',
        commandOptions: { isPlaying: true, fps: 24 },
        options: {
          keys: [
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.fps',
          ],
          values: [true, 24],
        },
      },
      {
        id: 'CineFPS60',
        label: 'Cine FPS[60]',
        icon: 'play',
        type: TOOLBAR_BUTTON_TYPES.STATE,
        commandName: 'cinePlay',
        commandOptions: { isPlaying: true, fps: 60 },
        options: {
          keys: [
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.fps',
          ],
          values: [true, 60],
        },
      },
      {
        id: 'CineFPS30',
        label: 'Cine FPS[30]',
        icon: 'play',
        type: TOOLBAR_BUTTON_TYPES.STATE,
        commandName: 'cinePlay',
        commandOptions: { isPlaying: true, fps: 30 },
        options: {
          keys: [
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.fps',
          ],
          values: [true, 30],
        },
      },
      {
        id: 'CineFPS15',
        label: 'Cine FPS[15]',
        icon: 'play',
        type: TOOLBAR_BUTTON_TYPES.STATE,
        commandName: 'cinePlay',
        commandOptions: { isPlaying: true, fps: 15 },
        options: {
          keys: [
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.fps',
          ],
          values: [true, 15],
        },
      },
      {
        id: 'CineFPS5',
        label: 'Cine FPS[5]',
        icon: 'play',
        type: TOOLBAR_BUTTON_TYPES.STATE,
        commandName: 'cinePlay',
        commandOptions: { isPlaying: true, fps: 5 },
        options: {
          keys: [
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.fps',
          ],
          values: [true, 5],
        },
      },
      {
        id: 'CineFPS1',
        label: 'Cine FPS[1]',
        icon: 'play',
        type: TOOLBAR_BUTTON_TYPES.STATE,
        commandName: 'cinePlay',
        commandOptions: { isPlaying: true, fps: 1 },
        options: {
          keys: [
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.isPlaying',
            'viewports.viewportSpecificData.Array.activeViewportIndex.cine.fps',
          ],
          values: [true, 1],
        },
      },
    ]
  },
  {
    id: 'Next',
    label: 'Next',
    icon: 'next',
    className: 'hideOnPhone',
    nonContexify: true,
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'nextImage',
    commandOptions: { toolName: 'Next' },
  },
  {
    id: 'Last',
    label: 'Last',
    icon: 'last',
    className: 'hideOnPhone',
    nonContexify: true,
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'lastImage',
    commandOptions: { toolName: 'Last' },
  },
  {
    id: 'Length',
    label: 'Annotation',
    icon: 'length',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
    commandName: 'setToolActive',
    commandOptions: { toolName: 'Length' },
    buttons: [
      {
        id: 'Length',
        label: 'Length',
        icon: 'length',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'Length',
        },
      },
      {
        id: 'Bidirectional',
        label: 'Bidirectional',
        icon: 'bidirection',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'Bidirectional',
        },
      },
      {
        id: 'RectangleRoi',
        label: 'Rectangle',
        icon: 'square',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'RectangleRoi',
        },
      },
      {
        id: 'EllipticalRoi',
        label: 'Ellipse',
        icon: 'ellipse',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'EllipticalRoi',
        },
      },
      {
        id: 'FreehandRoi',
        label: 'Freehand',
        icon: 'curve',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'FreehandRoi',
        },
      },
      {
        id: 'Angle',
        label: 'Angle',
        icon: 'angle',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'Angle',
        },
      },
      {
        id: 'ArrowAnnotate',
        label: 'Arrow',
        icon: 'arrow',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: { toolName: 'ArrowAnnotate' },
      },
      {
        id: 'DragProbe',
        label: 'Probe',
        icon: 'probe',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: {
          toolName: 'DragProbe',
        },
      },
      {
        id: 'divider01',
        type: TOOLBAR_BUTTON_TYPES.DIVIDER,
      },
      {
        id: 'Eraser',
        label: 'Eraser',
        icon: 'eraser',
        //
        type: TOOLBAR_BUTTON_TYPES.SET_TOOL_ACTIVE,
        commandName: 'setToolActive',
        commandOptions: { toolName: 'Eraser' },
      },
      {
        id: 'Clear',
        label: 'Clear',
        icon: 'trash',
        //
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'clearAnnotations',
      },
    ],
  },
  {
    id: 'vtkMPR',
    label: '3D',
    icon: 'mpr',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'mpr2d',
    buttons: [
      {
        id: 'vtkMPR',
        label: 'MPR',
        icon: 'mpr',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'mpr2d',
      },
      {
        id: 'vtkVR',
        label: 'VR',
        icon: 'vr',
        type: TOOLBAR_BUTTON_TYPES.COMMAND,
        commandName: 'vtkVR',
      },
    ],
  },
  {
    id: 'Download',
    label: 'Download',
    icon: 'download',
    className: 'hideOnPhone',
    type: TOOLBAR_BUTTON_TYPES.COMMAND,
    commandName: 'downloadJPEG',
    // commandName: 'downloadDICOM',
    // buttons: [
    //   {
    //     id: 'DownloadDICOM',
    //     label: 'Download DICOM',
    //     icon: 'download-dicom',
    //     className: 'hideOnPhone',
    //     type: TOOLBAR_BUTTON_TYPES.COMMAND,
    //     commandName: 'downloadDICOM',
    //   },
    //   {
    //     id: 'DownloadJPEG',
    //     label: 'Download JPEG',
    //     icon: 'download-jpeg',
    //     className: 'hideOnPhone',
    //     type: TOOLBAR_BUTTON_TYPES.COMMAND,
    //     commandName: 'downloadJPEG',
    //   },
    // ]
  },
];

export default {
  definitions,
  defaultContext: DEFAULT_CONTEXT,
};
